package pl.umk.mat.fred.unicore.urc.storagemanagement.unicore;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.w3.x2005.x08.addressing.EndpointReferenceType;

import de.fzj.unicore.rcp.identity.IdentityActivator;
import de.fzj.unicore.uas.util.AddressingUtil;
import de.fzj.unicore.wsrflite.xmlbeans.client.RegistryClient;

public class Registry {
	
	private String url;
	private RegistryClient client;
	private List<Storage> storageList;
	
	public Registry(String url, List<Storage> storageList) throws Exception {
		this.url = url;
		EndpointReferenceType ert = AddressingUtil.newEPR();
		ert.addNewAddress().setStringValue(url);
		client = new RegistryClient(ert, IdentityActivator.getDefault().getUASSecProps(url));
	}
	
	public synchronized String getUrl() {
		return url;
	}
	
	public synchronized void setUrl(String url) {
		this.url = url;
	}
	
	public synchronized RegistryClient getClient() {
		return client;
	}
	
	public synchronized void setClient(RegistryClient client) {
		this.client = client;
	}
	
	public synchronized List<Storage> getStorageList() {
		if (storageList == null) {
			storageList = Collections.synchronizedList(new ArrayList<Storage>());
		}
		return storageList;
	}
}
